package com.wanmait.translate.system.controller;

import com.wanmait.translate.pojo.SupplierTravel;
import com.wanmait.translate.system.service.impl.AuditedServiceImpl;
import com.wanmait.translate.utils.AuditEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/audit")
@CrossOrigin
public class AuditController {
    @Resource
    private AuditedServiceImpl auditedService;
    private static final Logger LOG= LoggerFactory.getLogger(AuditController.class);
    //出差审核
    @RequestMapping("/travleAudit")
    public SupplierTravel travleAudit(Integer id){
        return  auditedService.getIravleAuditInfo(id);
    }

    /*
     * @Author huweibin
     * @Description id：表id typeName：审核类型 要更新成的状态
     * @Date 9:08 2020/11/28
     **/
    @RequestMapping("/updateAudit")
    public void  updateAudit(String id,Integer typeId,Integer stateId,String day){
        LOG.info("接收到参数id：{id}：typeId：{typeId}：stateId：{stateId}：day：{day}",id,typeId,stateId,day);
        //根据typeId获得枚举类
        AuditEnum value = AuditEnum.values()[typeId];
        switch (value){
            //如果是出差审核
            case TRAVELED_AUDIT:{
                auditedService.updateAudit( id, stateId,day,value);
                break;
            }
        }
    }
}
